from core.basehandler import BaseHandler
from core.room import Room  
from core.action import Action
from core.player import Player

class Sea9RescueAttempt(Room):
    def __init__(self, room_id):
        Room.__init__(self, room_id)    # do basic initialization for every room
        
        # add inventory items
        
        # build list of actions
        self.add_action(Swim)
        self.add_action(Stay)
    
    # return description of room.
    def get_description(self):
        return "Congratulations, you got the Coast Guard's attention!  The Coast Guard rescue swimmer enters the water and you rejoice.  Unfortunately, you see him struggling in the pounding surf and he appears to be signaling to you.  Perhaps you should swim to them?"
    
    # return image of room
    def get_image(self):
        return 'sea9rescueattempt_pic.jpg'


class Sea9RescueAttemptHandler(BaseHandler):
    
    # return class to use to create a new instance of this room
    def get_room_class(self):
        return Sea9RescueAttempt

# define actions for this room

class Swim(Action):
    def __init__(self):
        Action.__init__(self, "Swim")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Swim to the Coast Guard swimmer"
    
    # return id of room to enter when action is complete
    def get_destination(self):
        return 'swimtoswimmerdeath'
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "get"
    
    def do_action(self,game,room,request):
        room.inventory.clear()
        player = game.get_player()
        player.inventory.clear()

class Stay(Action):
    def __init__(self):
        Action.__init__(self, "Stay")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Stay in the boat"
    
    # return id of room to enter when action is complete
    def get_destination(self):
        return 'swimmerarrives'
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "get"
    
    def do_action(self,game,room,request):
        room.inventory.clear()
        player = game.get_player()
        player.inventory.clear()
    